﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using ETL.Entity;
using ETL.Common.Logging;
namespace ETL.DataAccess
{
    public class ProjectResourceInstanceRepository
    {
        public IEnumerable<RESOURCE_INSTANCES> GetAllResourceInstances()
        {
            var db = new ETLDataEntities();
            var result = from s in db.RESOURCE_INSTANCES
                             orderby s.RESOURCE_NAME
                             select s;
            return result;
        }

        public RESOURCE_INSTANCES GetResourceInstanceByUser(string userId)
        {
            try
            {
                var db = new ETLDataEntities();
                var result = (from s in db.RESOURCE_INSTANCES
                              where s.RESOURCE_NAME.ToLower().Equals(userId.ToLower())
                              select s).FirstOrDefault();
                return result;
            }
            catch (Exception ex)
            {
                LogService.Service.Error(ex);
                return null;
            }
        }

    }
}

